package com.lry.pda.bottom.mysql.frontend;

public enum MysqlTokenType {
    //non-termals
    SELECT_STMT,QUERY_EXPR,QUERY_EXPR_BODY,OPT_ORDER_CLAUSE,OPT_LIMIT_CLAUSE,
    ORDER_ITEM,SELECT_ITEM_LIST,ORDER_ASC_DESC,FROM_CLAUSE,OPT_WHERE_CLAUSE,
    OPT_GROUP_CLAUSE,FIELD_LIST,FIELD_LIST_TERM,WHERE_CLAUSE,COMPARE,WHERE_CLAUSE_TERM,

    //terminals
    LIMIT_SYM,NUM_OR_ID,COMMA,ORDER_SYM,BY_SYM,ASC_SYM,DESC_SYM,SELECT_SYM,PLUS,TIMES,FIELD,
    FROM_SYM,TABLE,WHERE_SYM, STR,AND_SYM,EQ,LE,GE,LT,GT,IN,LP,RP,WHITE_SPACE,SEMI,GROUP_SYM,EOI,WHERE_VAL,UNKNOWN_TOKEN;

    public static final int FIRST_TERMINAL_INDEX = LIMIT_SYM.ordinal();
    public static  final int LAST_TERMINAL_INDEX = UNKNOWN_TOKEN.ordinal();

    public static final int FIRST_NON_TERMINAL_INDEX = SELECT_STMT.ordinal();
    public static final int LAST_NON_TERMINAL_INDEX = WHERE_CLAUSE_TERM.ordinal();

    public static String getSymbolStr(int val) {
        return MysqlTokenType.values()[val].toString();
    }

    public static boolean isTerminal(int val) {
        if (FIRST_TERMINAL_INDEX <= val && val <= LAST_TERMINAL_INDEX) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(getSymbolStr(22));
    }
}
